home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <!-- ===========================================================
- Category: XSLT
- Sub-category: xsl:message
- Author: David Silverlight
- HeadGeek@xmlpitstop.com
- Created: 2001-05-16
- Description:-
- This stylesheet demonstrates the use of xsl:message to
- display a message to the user based on a condition. In this
- stylesheet, an user-friendly error message is displayed when
- a language that can not be handled is found.
- =============================================================== -->
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:output method="html"/>
- <xsl:include href="Style.xsl" />
-
-
- <!-- Template for root rule -->
- <xsl:template match="/">
- <!-- Set Formatting Characteristics -->
- <xsl:call-template name="Style1"/>
- <xsl:apply-templates/>
- </xsl:template>
-
-
- <!-- Template for "employees" elements -->
- <xsl:template match="employees">
- <h1>Employee listing that will display a message to the user.</h1>
-
- <!-- Table Header Creation -->
- <table border="1">
- <tr>
- <th>Department</th>
- <th>Name</th>
- <th>Hourly Rate</th>
- <th>Programming Language</th>
- <th>Spoken Language</th>
- </tr>
-
-
- <xsl:for-each select="employee">
- <tr>
- <td><xsl:value-of select="department" /></td>
- <td><xsl:value-of select="employeename" /></td>
- <td><xsl:value-of select="hourlyrate" /></td>
- <td><xsl:value-of select="primarylanguage" /></td>
- <td>
- <xsl:choose>
- <xsl:when test="nativelanguage='EN'">
- <xsl:value-of select="'English'" />
- </xsl:when>
- <xsl:when test="nativelanguage='FR'">
- <xsl:value-of select="'French'" />
- </xsl:when>
- <xsl:when test="nativelanguage='SP'">
- <xsl:value-of select="'Spanish'" />
- </xsl:when>
- <xsl:when test="nativelanguage='TH'">
- <xsl:value-of select="'Thai'" />
- </xsl:when>
- <xsl:when test="nativelanguage='GR'">
- <xsl:value-of select="'German'" />
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:message terminate="no" >
- Error: Invalid language of: <xsl:value-of select="nativelanguage" />
- was found. "Unknown" will be used.
- </xsl:message>
-
- <xsl:value-of select="'Unknown'" />
- </xsl:otherwise>
-
- </xsl:choose>
- </td>
-
-
- </tr>
- </xsl:for-each>
-
-
-
-
- <!-- End of Table -->
- </table>
-
- </xsl:template>
-
-
-
-
-
- </xsl:stylesheet>